function validate_frmworks(){
    jQuery('#frmworks').length && jQuery('#frmworks').validate({
    	//ajax: true, -> chi su dung khi sumit ajax
    	rules: [
    		{
    			name: 'title',
    			required: true,
    			message: L10N.required.title
    		},
    		{
    			name: 'complate',
    			required: true,
    			message: L10N.required.complate
    		},
            {
    			name: 'order',
    			required: true,
    			message: L10N.required.order
    		}
            
    	],
    	alert: function( el ) {
    		var elWrapper = el.closest( '.uibutton' ),
    			layer = $( '<div class="alertLayer">' + el.data('message') + '</div>' );
    		el.focus();
    		layer
    			.appendTo( document.body )
    			.css({
    				'top': elWrapper.offset().top + elWrapper.height(),
    				'left': elWrapper.offset().left
    			//	'width': elWrapper.width() - 2
    			});
    		setTimeout(function() {
    			layer.remove();
    		}, 2000);
    	}
    });	  
}

function ISortTable()
{
    if (jQuery('#sortableLeft').length > 0 && jQuery('#sortableRight').length > 0) {
        $("#sortableLeft, #sortableRight").sortable({
			placeholder: "ui-state-highlight"
	    });
	    $("#sortableLeft, #sortableRight").disableSelection();    
     }
}

function complates() {
    /*
    jQuery('.complate').length && jQuery('.complate').bind('click', function() {
        var that = jQuery(this);	
        if(that.attr('rel').length) {
    		jQuery.ajax({
    			url: that.attr('rel'),
    			success: function(response){
    				if(response == 1){
    					//window.location.href = that.attr('rel');
                       alert('111111');
    				}
    				else if(response == 0){
    				    alert('0000');
    					//jQuery('#lnk-login').trigger('click');
    				}
    			}
    		});
    	}
    });
    */
     jQuery('tr td a.complate').length && jQuery('tr td a.complate').bind('click', function() {
        $(this).appendTo('hello world');
       /*
        var that = jQuery(this);	
        if(that.attr('rel').length) {
    		jQuery.ajax({
    			url: that.attr('rel'),
    			success: function(response){
    				if(response == 1){
    					//window.location.href = that.attr('rel');
                       alert('111111');
    				}
    				else if(response == 0){
    				    alert('0000');
    					//jQuery('#lnk-login').trigger('click');
    				}
    			}
    		});
    	} */
    });
    
}


jQuery( document ).ready(function() {
    validate_frmworks();
    complates();
    ISortTable();
});
